<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    // //四线对象深拷贝
    let obj = { name: "张贤", sex: "男", height: "180", hobby: ["打球", "唱歌"] }
    function copyObj(obj) {
        let obj2 = Array.isArray(obj) ? [] : {}
        for (let key in obj) {
            if (typeof obj[key] == 'object') {
                obj2[key] = copyObj(obj[key])
            }
            else {
                obj2[key] = obj[key]
            }
        }
        return obj2
    }
    let obj2 = copyObj(obj)
    obj.hobby.push('打游戏')
    console.log(obj);
    console.log(obj2);

    //大小写字母转换
    // let str = 'HelloWorld'
    // function fanZhuan(str) {
    //     let arr = str.split('')
    //     arr1 = []
    //     for (i = 0; i < arr.length; i++) {
    //         if (str.charCodeAt(i) > 97) {
    //             arr1[i] = arr[i].toUpperCase()
    //         }
    //         else {
    //             arr1[i] = arr[i].toLowerCase()
    //         }
    //     }
    //     let res = arr1.join('')
    //     console.log(res)
    // }
    // fanZhuan(str)

    // url解析
    // var str = "username=admin&password=123456"
    // function jiexi(){
    //     let srr = str.split('&')
    //     var obj = {}
    //     for(let i=0;i<arr.length;i++){
    //         let ele =arr[i].split('=')
    //         obj[ele[0]]=ele[1]
    //     }
    //     console.log(obj);
    // }
    // jiexi(str)
</script>